use tauri::AppHandle;

use crate::duplicate_file_analyzer::{self, AnalysisParameter, DuplicationAnalysisResult};

#[tauri::command]
pub async fn search_duplicate_file(
    app: AppHandle,
    param: AnalysisParameter,
) -> DuplicationAnalysisResult {
    if let Ok(result) = duplicate_file_analyzer::start_analysis(&app, param).await {
        return result;
    } else {
        DuplicationAnalysisResult::default()
    }
}

#[tauri::command]
pub async fn open_path(path: String) -> String {
    duplicate_file_analyzer::open_path(path).await
}

#[tauri::command]
pub async fn move_file_to_trash(file_path: String) -> String {
    duplicate_file_analyzer::move_file_to_trash(file_path).await
}

#[tauri::command]
pub fn cancel_processing(canceled: bool) {
    duplicate_file_analyzer::cancel_processing(canceled)
}
